package com.algorithm.code.list;

import java.util.List;

/**
 * @description TODO
 * @program: sudy
 * @author: kukuxiahuni
 * @create: 2020-01-23 16:01
 **/
public class Leetcode203 {

    public static void main(String[] args) {
        ListNode head = new ListNode(1);
        head.next = new ListNode(1);
        remove(head, 1);
    }

    public final static ListNode remove(ListNode head, int val) {
        if (head == null) {
            return head;
        }

        ListNode p = new ListNode(-1);
        p.next = head;
        ListNode dummy = p;

        while (p!=null && p.next != null) {
            if (p.next.val == val) {
                p.next = p.next.next;
                continue;
            }
            p = p.next;
        }

        return dummy.next;
    }
}
